package org.dim.oa.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.dim.oa.mapper.UserMapper;
import org.dim.oa.po.ServerResponse;
import org.dim.oa.po.UserEntity;
import org.dim.oa.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by lmj on 2021/3/19.
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserMapper userMapper;



    @RequestMapping("/get")
    public ServerResponse getUser(){
        return ServerResponse.success();
    }
    @RequestMapping("/update")
    public ServerResponse update(@RequestBody UserEntity userEntity){
        QueryWrapper queryWrapper = new QueryWrapper<UserEntity>();
        queryWrapper.eq("id",userEntity.getId());
        userEntity.setPassword(SecurityUtils.encodePassword(userEntity.getPassword()));
        userMapper.update(userEntity,queryWrapper);
        return ServerResponse.success("ok");
    }

}
